package web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import biz.AdminBiz;
import entity.Admin;
import util.BaseServlet;

public class AdminServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	AdminBiz adminbiz= new AdminBiz();
	
	public String login(HttpServletRequest req, HttpServletResponse res)
	{
		String username = req.getParameter("adminname");
		String password = req.getParameter("adminpwd");
		Admin admin = new Admin(username,password);
		Admin admin2 = adminbiz.findUser(admin);
		if(admin2 == null) {
			req.setAttribute("msg", "账号或密码错误");
			return "/adminjsps/login.jsp";
		}
		req.getSession().setAttribute("admin", admin2);
		return "r:/adminjsps/admin/index.jsp";
		
	}	
	
	public String exist(HttpServletRequest req, HttpServletResponse res)
	{
		req.getSession().removeAttribute("admin");;
		return "r:/adminjsps/admin/index.jsp";
		
	}

}
